#!/bin/bash

MY_DIR=`pwd`
output=$1
mkdir -p ./test_coverage_temp

#Reset all execution counts to zero.
lcov --zerocounters --directory .
#Capture coverage data. Reset counters
#lcov --capture --initial --directory . --output-file app

# Now run your test app in the same directory
$MY_DIR/Log/log_test
lcov --no-checksum --directory . --capture --output-file test_coverage_temp/log_test.info
$MY_DIR/core/core_test
lcov --no-checksum --directory . --capture --output-file test_coverage_temp/core_test.info

lcov --add-tracefile test_coverage_temp/log_test.info --add-tracefile test_coverage_temp/core_test.info --directory . --output-file test_coverage_temp/app.info
lcov --remove test_coverage_temp/app.info "/usr*" "*dev_libraries*" "*third_party*" -o test_coverage_temp/libbash_test.info
genhtml test_coverage_temp/libbash_test.info --output-directory $MY_DIR/$output

rm -rf ./test_coverage_temp